<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<%@ include file="/WEB-INF/views/include/head.jsp"%>
<script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
<script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
<title><spring:message code="bigcargo_style_list" /></title>
 <script src="${ctxStatic}/js/style.js"></script>
 <link rel="stylesheet" href="${ctxStatic}/css/list.css">
<script>
	<!-- 手动操作的通过总数  -->
	var accCount = 0;
	<!-- 画面项目总数 -->
	var labelAllList;
	<!-- 画面加载时已通过总数  -->
	var accNum;
	$(document).ready(function(){
	    <!-- 获取总行数 -->
		var trlength = $("td.table-No").length;
		for (var i = 1; i <= trlength; i++) {
			$("td.table-No")[i-1].innerHTML = i;
		}
	    <!-- 获取待检测总和 -->
		var labelWait =  $("label.wait").length;
	    <!-- 获取未通过总和 -->
		var labelNotAcc =  $("label.notaccess").length;
	    <!-- 获取通过总和 -->
		var labelAcc =  $("label.access").length;
		<!-- 画面加载时已通过总数  -->
		accNum = labelAcc;
		<!-- 画面项目总数 -->
		labelAllList = labelWait + labelNotAcc + labelAcc;
		for (var i = labelWait-1; i>=0; i--) {
	        var label = $("label.wait")[labelWait-1];
	        var $tr = $(label).parents("tr");
	        $("#customizationTable").find("tr:first").before($tr);
	    }
		for (var i = labelNotAcc-1; i>=0; i--) {
			var label = $("label.notaccess")[labelNotAcc-1];
			var $tr = $(label).parents("tr");
			$("#customizationTable").find("tr:first").before($tr);
		}
	    <!-- 计算窗体高度，出滚动条 -->
		var t = $(window).scrollTop();
	    <!-- 按钮绑定点击事件 -------------------------start---- -->
		$("#btnDown").click(function(){
			if (t<(115*(trlength-3))) {
				t += 115
			}
		    $('div.divOverflw').animate({'scrollTop':t},100)
	
		})
		$("#btnUp").click(function(){
			if (t>0) {
				t -= 115
			}
		    $('div.divOverflw').animate({'scrollTop':t},100)
	
		})
	    <!-- 按钮绑定点击事件 -------------------------end---- -->
	})
	
    /**通过or未通过按钮操作
     * obj:当前按钮对象
     * type:通过未通过区分
     * qcId:质检流程表主键
     * **/
	function changeTrLast(obj,type,qcId) {
		<!-- 计算操作的通过数 -----------------------start---  -->
		<!-- 获取当前项目的对象 -->
		var thisQcCheck = $($(obj).parent()).find(".thisQcCheck");
		<!-- 获取当前项目的初始值 -->
		var thisQcCheckVal = $($(obj).parent()).find(".thisQcCheck").val();
    	if (thisQcCheckVal == "0") {
			if (type == "1") {
				$(thisQcCheck).val("1");
				accCount = accCount + 1;
			}
		}else if (thisQcCheckVal == "1"){
			if (type == "2") {
				$(thisQcCheck).val("2");
				accCount = accCount - 1;
			}
		}else if (thisQcCheckVal == "2"){
			if (type == "1") {
				$(thisQcCheck).val("1");
				accCount = accCount + 1;
			}
		}
		<!-- 计算操作的通过数 ------------------------end---  -->
        <!-- 获取按钮名称 -->
		var buttonText = obj.innerText;
        <!-- 获取上节对象 -->
		var $tr = $(obj).parents("tr");
        <!-- 获取更新时间 -->
		var updateTime = $("#updateTime").val();
        <!-- 获取操作者名称 -->
		var userName = $("#userName").val();
        <!-- 获取value+code -->
		var inputVal = $($tr).find(".inputOne")[0].value+"-"+$($tr).find(".inputTwo")[0].value;
        <!-- 区分为[1]的时候，按钮样式发生变化 -->
		if (type==1) {
			obj.style="background-color: #00B83F;";
			$($tr).find(".btnTemp2")[0].style="background-color: gray;float:right;";
			$($tr).find("label.labelHtml").removeClass('inputColorRed');
        <!-- 区分为[2]的时候，按钮样式发生变化 -->
		}else if (type==2) {
			obj.style="background-color: red;float:right;";
			$($tr).find(".btnTemp")[0].style="background-color: gray;";
			$($tr).find("label.labelHtml").addClass('inputColorRed');
		}
        <!-- -----------赋值------------------------------start--- -->
		$($tr).find(".userName")[0].innerHTML = userName;
		$($tr).find(".updateDate")[0].innerHTML = updateTime;
		$($tr).find("label.labelHtml").text(buttonText);
		var itemId = '${itemId}';
		var styleID = $("#styleID").val();
		var orderID = $("#orderID").val();
		var styleBarCode = $("#styleBarCode").val();
        <!-- -----------赋值------------------------------end--- -->
        <!-- 把form中的对应hidden变成可提交状态 -->
		$("#allChangeUpdate").find("."+qcId).val(type);
         <!-- 如果当前状态是未通过并且是关键工序，直接返回扫码画面，订单表对应更新。-->
		if (type==2 && (inputVal=="QC_ORDER-QORNO"||inputVal=="SHIRT_DESIGN_SMA-4SMA"||inputVal=="QC_MATERIAL_NO-QMANO"||inputVal=="SHIRT_DESIGN_SGD-4SGD")) {
            $("#orderStatus_Update").val("QUALITY_STATUS-QC_03");
            $("#changeFlg").val("1");
            var params = $("#allChangeUpdate").serialize();
			$.post("${ctx}/customization/quality/saveOrderStatus",params,function(){
                <!-- 保存当前订单的工序状态 -->
				tipParent("<spring:message code="customization_message_dataError"/>",3000);
				goBackHtml();
				return;
			},'json');
		}
		$("#customizationTable").find("tr:last").after($tr);
		<!-- 如果全部通过，自动提交 -->
		if (accCount + accNum == labelAllList) {
			saveData(true);
		}
	}
    
    /**保存当前订单的工序状态
     * flg:操作区分 true:下一步按钮; false:重大错误是调用
     * **/
	function saveData(flg) {
        <!--  数据异常情况 -->
        if ($(".inputOne")[0] == undefined) {
            tipParent("<spring:message code="System_error_please_contact_your_administrator"/>",3000);
        } else {
            $("#allChangeUpdateInputOne").val($(".inputOne")[0].value);
            $("#allChangeUpdateInputTwo").val($(".inputTwo")[0].value);
            $("#changeFlg").val("0");
            var params = $("#allChangeUpdate").serialize();
            $.post("${ctx}/customization/quality/saveData",params,function(result){
                <!-- 当前质检全部通过 -->
                if (result == "OK") {
                    if (flg) {
                        tipParent("<spring:message code="customization_message_allChecked"/>",3000);
                        goBackHtml();
                    }
                <!-- 系统错误 -->
                } else if (result == "NG") {
                    tipParent("<spring:message code="System_error_please_contact_your_administrator"/>",3000);
                 <!-- 全部是待检测状态 ，无变化状态 -->
                } else if (result == "noChange"){
                    goBackHtml();
                 <!--  包含未通过和待检测状态 -->
                } else {
                    tipParent("<spring:message code="customization_message_all_Fail"/>",10000);
                    goBackHtml();
                }
            });
        }
	}
    
    /**
     * 返回扫码画面
     * **/
	function goBackHtml(){
        var labelLength = $(".labelHtml").length;
        <!-- 待检测数量  -->
        var labelWait =  0;
        <!-- 未通过数量  -->
        var labelNotAcc =  0;
        <!-- 通过数量  -->
        var labelAcc =  0;
        for (var i = 0; i < labelLength; i++) {
            if ($(".labelHtml")[i].innerHTML=="<spring:message code="customization_status_wait"/>") {
                labelWait++;
            }else if ($(".labelHtml")[i].innerHTML=="<spring:message code="customization_status_notaccess"/>") {
                labelNotAcc++;
            }else if ($(".labelHtml")[i].innerHTML=="<spring:message code="customization_status_access"/>") {
                labelAcc++;
            }
        }
        <!-- 工序ID -->
        var itemId = '${itemId}';
        <!-- 订单ID -->
        var orderID = $("#orderID").val();
        var orderNO = "${orderInfo.orderNO }";
        <!-- 初始待检测  -->
        var intNum = "";
        if ((labelNotAcc + labelAcc)>0) {
            if (labelNotAcc>0) {
                intNum = "QUALITY_STATUS-QC_02";
            }else if (labelNotAcc == 0 && labelWait == 0) {
                intNum = "QUALITY_STATUS-QC_01";
            }
        }else{
            intNum = "QUALITY_STATUS-QC_00";
        }
        if (intNum != "QUALITY_STATUS-QC_00") {
            $.post("${ctx}/customization/quality/saveProItem?orderID="+orderID+"&customOrderNO="+orderNO+"&orderStatus="+intNum+"&itemId="+itemId,"",function(result){
                window.location.href="${ctx}/customization/quality/?operatingId="+itemId;
            },'json');
        }else{
            window.location.href="${ctx}/customization/quality/?operatingId="+itemId;
        }
	}
    
</script>
	<style>
		.btnTemp,.btnTemp2 {
			border: none;
			text-align: center;
			font-size: 13px;
			width: 60px;
			height: 60px;
			
			margin: 3px 13px 3px 7px;
		}
		.btnUpDown{
			border: none;
			text-align: center;
			font-size: 18px;
			width: 70px;
			height: 40px;
		}
        .inputColorRed{ color :red ;}
        
        .a_demo_four {
			background-color:#1d1a19b3;
			font-family: 'Open Sans', sans-serif;
			font-size:13px;
			text-decoration:none;
			color:#fff;
			position:relative;
			/* padding:40px 30px;
			padding-right:50px; */
			border-radius: 5px;
			box-shadow: inset 0px 1px 0px #9e8d84, 0px 5px 0px 0px #180e0900, 0px 10px 5px #999;
		}
		
		.a_demo_four:active {
			top:3px;
		
			box-shadow: inset 0px 1px 0px #9e8d84, 0px 2px 0px 0px #322620, 0px 5px 3px #999;
		}
	</style>
</head>
<body>
<form id="inputForm">
<input type="hidden" id="styleBarCode" value="${orderInfo.styleBarCode}"/>
<input type="hidden" id="updateTime" value="${fns:getDate('yyyy-MM-dd')}"/>
<input type="hidden" id="userName" value="${orderInfo.createBy.firstName}${orderInfo.createBy.lastName}"/>
	<div class="listArea" id="activity_pane">
		<c:choose>
		<c:when test="${itemId == 36}">
			<div class="listBg" style="height: 710px;width: 1060px;">
			</c:when>
			<c:otherwise>
				<div class="listBg" style="height: 690px;width: 1060px;">
				</c:otherwise>
				</c:choose>
			<div class="items clearfix">
				<div class="col-50 clearfix">
					<!-- 定制订单质检 -->
					<strong style="font-size:15px;"><spring:message code="customization_fit_quality"/></strong>
				</div>
			</div>
			<div class="searchArea clearfix" style="border:1px solid #13031e33;width:1020px;position:relative;left:10px;top:-10px;">
				<div class="items clearfix">
				<div class="col-16 clearfix haveToBox">
					<!-- 内部订单号 -->
					<p class="tit" style="width:90px;">
						<spring:message code="customization_order"/>
					</p>
					<label>${orderInfo.styleNo }</label>
					<input type="hidden" id="styleID" name="styleID" value="${orderInfo.styleId }"/>
					<input type="hidden" id="orderID" name="orderID" value="${orderInfo.id }"/>
				</div>
				<div class="col-16 clearfix haveToBox">
					<!-- 交期重要 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="customization_important_flg"/>
					</p>
					<label>${fns:getDictName(orderInfo.urgentCD) }</label>
				</div>
				<div class="col-16 clearfix haveToBox">
					<!-- 订单日期 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="order_orderDate"/>
					</p>
					<label><fmt:formatDate value="${orderInfo.orderDate }" pattern="yyyy-MM-dd"/></label>
				</div>
			</div>
			<div class="items clearfix">
				<div class="col-16 clearfix haveToBox">
					<!-- 客户订单号 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="inventory_requestex_list_search_indentNo"/>
					</p>
					<label>${orderInfo.orderNO }</label>
				</div>
				<div class="col-16 clearfix haveToBox">
					<!-- 特殊订单 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="customization_specl_order"/>
					</p>
					<label>${orderInfo.specialOder }</label>
				</div>
				<div class="col-16 clearfix haveToBox">
					<!-- 船期 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="order_chuanqi"/>
					</p>
					<label><fmt:formatDate value="${orderInfo.targetDate }" pattern="yyyy-MM-dd"/></label>
				</div>
			</div>
			<c:if test="${itemId == 36}">
			<div class="items clearfix">
				<div class="col-16 clearfix haveToBox">
					<!-- 前立 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="customization_specl_4sfp"/>
					</p>
					<label><b style="color: red">${fns:getDesignoptionName(orderInfo.sfpControl) }</b></label>
				</div>
				<div class="col-16 clearfix haveToBox">
					<!-- 后省 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="customization_specl_4sbd"/>
					</p>
					<label><b style="color: red">${fns:getDesignoptionName(orderInfo.sbdControl) }</b></label>
				</div>
				<div class="col-16 clearfix haveToBox">
					<!-- 水洗要求 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="customization_specl_4wayes"/>
					</p>
					<label><b style="color: red">${fns:getDesignoptionName(orderInfo.washControl) }</b></label>
				</div>
			</div>
			</c:if>
			<div class="items clearfix">
				<div class="clearfix haveToBox">
					<!-- 备注 -->
                    <p class="tit" style="width:90px;">
						<spring:message code="common_remarks"/>
					</p>
					<label><b style="color: red">${orderInfo.remarks }</b></label>
				</div>
			</div>
			</div>
			<div class="tableArea" style="top:-11px;">
				<c:choose>
					<c:when test="${itemId == 36}">
					<div class="divOverflw" style="overflow:auto ;width:1040px;height:457px;">
					</c:when>
					<c:otherwise>
						<div class="divOverflw" style="overflow:auto ;width:1040px;height:477px;">
					</c:otherwise>
				</c:choose>
					<table cellpadding="0" class="tableHead" style="width: 1020px; z-index: 999;">
						<thead>
						<tr>
							<!-- No. -->
							<th class="table-No">
								<spring:message code="common_no"/>
							</th>
							<!-- 检查项目 -->
							<th style="width:150px">
								<spring:message code="customization_project"/>
							</th>
							<!-- 订单尺寸 -->
							<th style="width:150px;">
								<spring:message code="customization_order_content"/>
							</th>
                            <!-- 差额 -->
                            <th style="width:90px;">
                                <spring:message code="chazhi"/>
                            </th>
                            <%-- <!-- 实际尺寸 -->
                            <th style="width:150px;">
                                <spring:message code="fit_wriate"/>
                            </th> --%>
                            <!-- 检查结果 -->
							<th style="width:130px;">
								<spring:message code="customization_result"/>
							</th>
							<!-- 状态 -->
							<th style="width:60px;">
								<spring:message code="customization_status"/>
							</th>
							<!-- 质检员 -->
							<th style="width:80px">
								<spring:message code="customization_user"/>
							</th>
							<!-- 质检日期 -->
							<th style="width:90px;">
								<spring:message code="customization_date"/>
							</th>
							</tr>
						</thead>
						</table>
						<table cellpadding="0" class="tableBody" id="customizationTable" style="margin-top: 46px;width:1020px;">
						<tbody>
						<c:forEach items="${styleQualityList }" var="styleQuality" varStatus="status">
						<c:if test="${styleQuality.optionValue!=null&&styleQuality.optionValue!=''&&styleQuality.optionValue!='-' }">
						<tr style="height: 80px">
							<!-- No. -->
							<td class="table-No"></td>
							<!-- 检查项目 -->
							<td style="width:150px">
								<p>${styleQuality.qcItem }</p>
							</td>
							<!-- 订单尺寸 -->
							<td style="width:150px;">
                                <p>${styleQuality.optionValue}<br>${fns:getDesignoptionName(styleQuality.optionValue)}<c:if test="${fns:getDesignoptionRemark(styleQuality.optionValue)!=''}"><br>${fns:getDesignoptionRemark(styleQuality.optionValue)}</c:if></p>
							</td>
                            <%-- <!-- 实际尺寸 -->
                            <td style="width:100px;" align="center">
								<c:if test="${styleQuality.qcCheck=='0' }">
									<input type="text" id="wriateFitVal" value="${styleQuality.fitValue}" style="width:100px;height:70px;border-left:0px;border-top:0px;border-right:0px;border-bottom:1px" oninput="checkNum(this)" >
								</c:if>
								<c:if test="${styleQuality.qcCheck=='2' }">
									<input type="text" id="wriateFitVal" class ="inputColorRed" value="${styleQuality.fitValue}" style="width:100px;height:70px;border-left:0px;border-top:0px;border-right:0px;border-bottom:1px" oninput="checkNum(this)" >
								</c:if>
								<c:if test="${styleQuality.qcCheck=='1' }">
									<input type="text" id="wriateFitVal" value="${styleQuality.fitValue}" style="width:100px;height:70px;border-left:0px;border-top:0px;border-right:0px;border-bottom:1px" oninput="checkNum(this)" >
								</c:if>
                            </td> --%>
                            <!-- 差值范围 -->
                            <td style="width:90px;">
                                <p><spring:message code="balance"/></p>
                            </td>
                            <!-- 检查结果 -->
							<td style="width:130px;" >
							<shiro:hasPermission name="customization:quality:edit">
							<c:if test="${styleQuality.qcCheck=='0' }">
								<button type="button" style="background-color: gray;" class="btnTemp a_demo_four" onclick="changeTrLast(this,1,'${styleQuality.qcId }')"><spring:message code="customization_status_access"/></button>
								<button type="button" style="background-color: gray;float:right;" class="btnTemp2 a_demo_four" onclick="changeTrLast(this,2,'${styleQuality.qcId }')"><spring:message code="customization_status_notaccess"/></button>
							</c:if>
							<c:if test="${styleQuality.qcCheck=='1' }">
								<button type="button" style="background-color: #00B83F;" class="btnTemp a_demo_four" onclick="changeTrLast(this,1,'${styleQuality.qcId }')"><spring:message code="customization_status_access"/></button>
								<button type="button" style="background-color: gray;float:right;" class="btnTemp2 a_demo_four" onclick="changeTrLast(this,2,'${styleQuality.qcId }')"><spring:message code="customization_status_notaccess"/></button>
							</c:if>
							<c:if test="${styleQuality.qcCheck=='2' }">
								<button type="button" style="background-color: gray;" class="btnTemp a_demo_four" onclick="changeTrLast(this,1,'${styleQuality.qcId }')"><spring:message code="customization_status_access"/></button>
								<button type="button" style="background-color: red;float:right;" class="btnTemp2 a_demo_four" onclick="changeTrLast(this,2,'${styleQuality.qcId }')"><spring:message code="customization_status_notaccess"/></button>
							</c:if>
							</shiro:hasPermission>
							<input type="hidden" class="thisQcCheck" value="${styleQuality.qcCheck }"/>
							</td>
							<!-- 状态  -->
							<td style="width:60px;">
							<c:if test="${styleQuality.qcCheck=='0' }">
								<label style="width: 20px" class="labelHtml wait"><spring:message code="customization_status_wait"/></label>
							</c:if>
							<c:if test="${styleQuality.qcCheck=='1' }">
								<label style="width: 20px" class="labelHtml access"><spring:message code="customization_status_access"/></label>
							</c:if>
							<c:if test="${styleQuality.qcCheck=='2' }">
								<label style="width: 20px" class="labelHtml notaccess inputColorRed"><spring:message code="customization_status_notaccess"/></label>
							</c:if>
							</td>
							<!-- 质检员 -->
							<td style="width:80px">
								<label class="userName">${styleQuality.createBy.firstName }</label>
							</td>
							<!-- 质检日期 -->
							<td style="width:90px;">
							<label class="updateDate"><fmt:formatDate value="${styleQuality.updateDate }" pattern="yyyy-MM-dd"/></label>
								<%-- ${fns:getDate("yyyy-MM-dd")} --%>
							</td>
                            <input type="hidden" class="inputOne" name="itemCode" value="${styleQuality.itemCode }"/>
                            <input type="hidden" class="inputTwo" name="itemValue" value="${styleQuality.itemValue }"/>
						</tr>
						</c:if>
						</c:forEach>
						</tbody>
					</table>
				</div>
				<div class="items clearfix">
					<button style="width: 60px; height: 40px;margin-top: 7px;" type="button" onclick="saveData(true);">下一个</button>
				</div>
			</div>
		</div>
	</div>
</form>
<form id="allChangeUpdate">
    <c:forEach items="${styleQualityList }" var="styleQuality" varStatus="status">
        <c:if test="${styleQuality.optionValue!=null&&styleQuality.optionValue!=''&&styleQuality.optionValue!='-' }">
            <c:if test="${styleQuality.itemCode!='QC_SBO_7'&&styleQuality.itemCode!='QC_SBA_2'&&styleQuality.itemCode!='QC_SBD_3'&&styleQuality.itemCode!='QC_SFP_8'&&styleQuality.itemCode!='QC_SSL_5'&&styleQuality.itemCode!='QC_SCU_5'&&styleQuality.itemCode!='QC_SBS_5'&&styleQuality.itemCode!='QC_SBA_1'}">
                <c:if test="${orderInfo.sleeveFlag == 0 }">
                    <input type="hidden" class = "qcId" name ="strQcId" value="${styleQuality.qcId }" />
                    <input  type="hidden" class = "${styleQuality.qcId }" name ="qcCheck" value="${styleQuality.qcCheck }"/>
                </c:if>
                <c:if test="${orderInfo.sleeveFlag == 1 }">
                    <c:if test="${styleQuality.itemValue!='4SSV'&&styleQuality.itemValue!='SSV1'&&styleQuality.itemValue!='SSV2'&&styleQuality.itemValue!='SCU3'}">
                        <input type="hidden" class = "qcId" name ="strQcId" value="${styleQuality.qcId }" />
                        <input  type="hidden" class = "${styleQuality.qcId }" name ="qcCheck" value="${styleQuality.qcCheck }"/>
                    </c:if>
                </c:if>
            </c:if>
        </c:if>
    </c:forEach>
	<input type="hidden" id="allChangeUpdateInputOne" name="itemCode" value=""/>
	<input type="hidden" id="allChangeUpdateInputTwo" name="itemValue" value=""/>
	<input type="hidden"  name="styleID" value="${orderInfo.styleId }"/>
	<input type="hidden"  name="orderID" value="${orderInfo.id }"/>
	<input type="hidden"  name="itemId" value="${itemId}"/>
    <input type="hidden"  id="orderStatus_Update" name="orderStatus" value=""/>
    <input type="hidden"  id="changeFlg" name="changeFlg" value=""/>
</form>
</body>
</html>
